package com.szt.mobile.inventory.common.ui;

import android.app.Activity;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.widget.Toast;

import com.isoftstone.mis.ffair.ui.loading.FFLoading;
import com.szt.mobile.inventory.common.utils.ToastUtils;

/**
 * Created by yanzhaodi on 2017/9/13.
 */

public class BaseActivity extends Activity {

    private FFLoading ffLoading;

    protected void showLoading() {

        if (null == ffLoading) {
            ffLoading = FFLoading.create(this);
        }

        ffLoading.show();
    }

    protected void hideLoading() {
        if (null != ffLoading) {
            ffLoading.dismiss();
        }
    }

    protected void showToast(String message) {

        if (TextUtils.isEmpty(message)){
            message = "message为空";
        }
        final Toast toast = Toast.makeText(this, message, Toast.LENGTH_SHORT);
        runOnUiThread(new Runnable() {
            @Override
            public void run() {
                toast.setGravity(Gravity.CENTER,0, 0);
                toast.show();
            }
        });

    }

    public void exit(View view) {
        finish();
    }

}
